import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class TestTabWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return TestTabState();
  }
}

class TestTabState extends State<TestTabWidget>
    with SingleTickerProviderStateMixin {
  List<Tab> list;
  TabController controller;

  @override
  void initState() {
    super.initState();
    Tab tab = Tab(text: "1");
    list = List()..add(tab)..add(tab)..add(tab)..add(tab);
    controller =
        TabController(length: list.length, vsync: this, initialIndex: 0);
    controller.addListener(() {
      switch (controller.index) {
        case 0:
          print("111111111111111111111111111");
          break;
        case 1:
          print("22222222222222222222222");
          break;
        case 2:
          print("333333333333333333333333");
          break;
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    var tabBar = TabBar(
      tabs: list,
      controller: controller,
    );
    return tabBar;
  }
}
